package com.dbMethod;

import com.lUtils.jdbcUtils;

import java.sql.*;

public class sql_LoginCheck {
    /**
     * 账户登入监测
     * @param CardId 卡号
     * @param password 密码
     * @return 返回是否查到有对应账户
     */
    public static boolean LoginCheck(String  CardId,int password) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String resultCardId=null;
        boolean flag=false;
        try{
            con= jdbcUtils.getConnection();
            ps=con.prepareStatement("SELECT cardID FROM cardinfo  WHERE cardID=? AND  `password`=? ");
            ps.setString(1,CardId);
            ps.setInt(2,password);
            rs=ps.executeQuery();
            if(rs.next()){
                resultCardId=rs.getString("cardID");
            }
            if(CardId.equals(resultCardId)){
                flag=true;
            }
            return flag;

        }catch (SQLException e){
            e.printStackTrace();
            return flag;
        }
        finally {
            jdbcUtils.closeTheStream(rs, ps, con);

        }

    }
}
